home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / Asm / 24BitChunky / cyberdirect.s < prev    next >
Encoding:
Text File  |  1996-08-19  |  4.8 KB  |  225 lines

  1.  
  2. StartSkip    =    0        ;0=WB/CLI, 1=CLI only (eg. from AsmOne)
  3. Processor    =    68020        ;0/680x0 (= 0 is faster than 68000)
  4. MathProc    =    0        ;FPU: 0(none)/68881/68882/68040
  5.  
  6. A        = 0
  7. B        = 1
  8.  
  9.         ; set which cia timer to use
  10.  
  11. CIAchip        = B
  12. TIMER        = B
  13.  
  14. MicroTiming    = 20000        ; interval timing for faked VerticalBlank
  15.  
  16.  
  17.         include    "startup.asm"    ; get NewStartupxx.lha from AmiNet!!
  18.  
  19.         include    "exec/exec.i"
  20.         include    "exec/exec_lib.i"
  21.         include    "dos/dos_lib.i"
  22.         include    "intuition/intuition.i"
  23.         include    "intuition/intuition_lib.i"
  24.         include    "graphics/graphics_lib.i"
  25.         include    "graphics/rastport.i"
  26.         include    "hardware/cia.i"
  27.         include    "resources/cia_lib.i"
  28.         include    "cybergraphics/cybergraphics.i"
  29.         include    "cybergraphics/cybergraphics_lib.i"
  30.         include "devices/input.i"
  31.         include "devices/inputevent.i"
  32.  
  33.         include    "depmacros_ns.i"
  34.         include    "inc/input.i"
  35.         include    "cia.i"
  36.  
  37.         dc.b    "$VER: CyberDirect 0.0001 © Andreas Fredriksson",0
  38.         even
  39.  
  40. *-------------------------------------------------------*
  41. *                Inits for starup.asm        *
  42. *-------------------------------------------------------*
  43.  
  44. Init:
  45. Devpac:        TaskName "<Rendering>"
  46.  
  47.         TaskPri    10            ;set task pri, optional
  48.  
  49.         ; define the libraries
  50.  
  51.         DefLib    cybergraphics,40
  52.         DefLib    graphics,39
  53.         DefLib    intuition,39
  54.         DefLib    dos,39
  55.         DefEnd                ;ALWAYS REQUIRED!!!
  56.  
  57. *-------------------------------------------------------*
  58. *              Start off                *
  59. *-------------------------------------------------------*
  60.  
  61. Start        bsr.w    GetCIA            ; allocate a CIA timer
  62.         bne    ciaerror
  63.  
  64.         LibBase    cybergraphics
  65.         suba.l    a0,a0            ; requester: not used
  66.         lea.l    requestertags,a1
  67.         Call    CModeRequestTagList    ; get a mode
  68.         tst.l    d0
  69.         beq    Exit
  70.         move.l    d0,mode_insert+4   ; save modeid in screen taglist
  71.  
  72.         suba.l    a0,a0
  73.         lea.l    screentags,a1
  74.         CallInt    OpenScreenTagList  ; open the screen
  75.         tst.l    d0
  76.         beq    Exit
  77.         move.l    d0,screen
  78.         add.l    #sc_RastPort,d0
  79.         move.l    d0,rastport    ; save rport address
  80.  
  81.         suba.l    a0,a0
  82.         lea.l    windowtags,a1
  83.         CallInt    OpenWindowTagList  ; open a dummy window...
  84.         tst.l    d0
  85.         beq    Exit
  86.         move.l    d0,window
  87.  
  88.         move.l    window,a0
  89.         lea.l    sprite,a1
  90.         moveq.w    #0,d0
  91.         moveq.w    #0,d1
  92.         moveq.w    #0,d2
  93.         moveq.w    #0,d3
  94.         CallInt    SetPointer    ; ...for blanking the mouse!
  95.  
  96.         bsr.w    StartHandler    ; install the inputhandler!
  97.         beq    Exit
  98.  
  99.         bsr.w    UpdateBuffer    ; black screen
  100.  
  101. .ll        tst.w    _Quit        ; no ugly $bfe001!
  102.         bne    Exit
  103.  
  104.         bsr.w    Render        ; do your stuff in the 24-bit buffer..
  105.         bsr.w    UpdateBuffer    ; ..and put the results in the screen!
  106.         bra.s    .ll        ; loop again!
  107.  
  108.  
  109. Exit        tst.w    handler        ; some nice exit code
  110.         beq.s    .nohandler
  111.         bsr.w    StopHandler
  112.  
  113. .nohandler    tst.l    window
  114.         beq.s    .nowin
  115.         move.l    window,a0
  116.         CallInt    CloseWindow
  117.  
  118. .nowin        tst.l    screen
  119.         beq.s    .noscr
  120.         move.l    screen,a0
  121.         CallInt    CloseScreen
  122.  
  123. .noscr        bsr.w    FreeCIA
  124.         Return    0            ;return code and bye bye!
  125. ciaerror    Return    20
  126.  
  127.  
  128.  
  129.  
  130. *-------------------------------------------------------*
  131. *                 Update 24bit buffer            *
  132. *   Could easily be modified here for direct rendering  *
  133. *              using the lock-functions!        *
  134. *-------------------------------------------------------*
  135.  
  136. UpdateBuffer    lea.l    RGBChunky,a0
  137.         move.l    rastport,a1
  138.         clr.w    d0
  139.         clr.w    d1
  140.         move.w    #4*320,d2        ; bytes per line in source
  141.         clr.w    d3
  142.         clr.w    d4
  143.         move.w    #320,d5
  144.         move.w    #240,d6
  145.         move.w    #RECTFMT_ARGB,d7
  146.         CallCyb    WritePixelArray
  147.         rts
  148.  
  149.  
  150. *-------------------------------------------------------*
  151. *              Render                *
  152. *-------------------------------------------------------*
  153.  
  154. Render
  155.         ; the chunky buffer is yours!
  156.  
  157.         rts
  158.  
  159. *-------------------------------------------------------*
  160. *               Data                *
  161. *-------------------------------------------------------*
  162.  
  163. ;StartShow    dc.w    0
  164.  
  165. reqtitle    dc.b    "Pick a 24bit screenmode!",0
  166.         even
  167. requestertags    dc.l    CYBRMREQ_WinTitle,reqtitle
  168.         dc.l    CYBRMREQ_MinWidth,320    ; sorry, hardcoded screen
  169.         dc.l    CYBRMREQ_MaxWidth,320    ; just change if you want more
  170.         dc.l    CYBRMREQ_MinHeight,240
  171.         dc.l    CYBRMREQ_MaxHeight,240
  172.         dc.l    CYBRMREQ_MinDepth,24    ; minimum depth
  173.         ;dc.l    CYBRMREQ_MaxDepth,32
  174.         dc.l    0,0
  175.  
  176. rastport    dc.l    0
  177.  
  178. screentags    dc.l    SA_Left,0
  179.         dc.l    SA_Top,0
  180.         dc.l    SA_Width,320
  181.         dc.l    SA_Height,240
  182.         dc.l    SA_Depth
  183. mode_depth    dc.l    32
  184.         dc.l    SA_Type,CUSTOMSCREEN
  185. mode_insert    dc.l    SA_DisplayID,0
  186.         dc.l    SA_Draggable,0
  187.         dc.l    SA_Exclusive,1
  188.         dc.l    0,0        
  189.  
  190. window        dc.l    0
  191. windowtags    dc.l    WA_Left,0
  192.         dc.l    WA_Top,0
  193.         dc.l    WA_Width,20
  194.         dc.l    WA_Height,20
  195.         dc.l    WA_CustomScreen
  196. screen        dc.l    0
  197.         dc.l    WA_Borderless,1
  198.         ;dc.l    WA_Backdrop,1
  199.         dc.l    WA_BackFill,LAYERS_NOBACKFILL
  200.         dc.l    WA_Activate,1
  201.         dc.l    0,0
  202.  
  203.         Section    Chunky,BSS_F
  204.  
  205. RGBChunky    ds.b    320*240*4
  206.  
  207.         section    blaha,data_C
  208.  
  209. sprite        dc.l    0,0,0,0        ; dummy for clearing the sprite!
  210.  
  211.  
  212. *-------------------------------------------------------*
  213. *          Faked VBL interrupt via CIA timing!        *
  214. *-------------------------------------------------------*
  215.  
  216.         Section    CIA_INT,Code_F
  217.  
  218. cia_Interrupt    movem.l    a2-a6/d2-d7,-(sp)
  219.  
  220.         ; do syncs here!
  221. .leave
  222.         movem.l    (sp)+,a2-a6/d2-d7
  223.         clr.w    d0
  224.         rts
  225.